package com.cez.itstudio01.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.cez.itstudio01.pojo.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
* @author LEGION
* @description 针对表【user】的数据库操作Mapper
* @createDate 2022-09-07 22:52:56
* @Entity com.cez.itstudio01.pojo.User
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {
    @Select("SELECT * FROM  user WHERE ID = #{ID} and password=#{password}")
    User login(String ID,String password);

    //@Select("SELECT * FROM user ${ew.customSqlSegment} LIMIT #{page},#{limit}")
    //List<User> get(Integer page,Integer limit,@Param(Constants.WRAPPER) Wrapper<User> wrapper);

    List<User> get(Integer page,Integer limit1,String id,String name,String limit);

    @Insert("INSERT INTO user ( id, name,password,`limit`,grade,book1_ID,book2_ID ) VALUES ( #{id}, #{name},#{password},#{limit},#{grade},#{book1Id},#{book2Id} )")
    int addUser(User user);

    @Select("SELECT * FROM  user WHERE ID = #{ID}")
    User getByID(String ID);

    @Update("UPDATE user  SET book1_ID=#{book1_ID} ,book2_ID=#{book2_ID} WHERE ID=#{ID}")
    int updateUser(String ID,String book1_ID,String book2_ID);
}




